package com.tomkid.naojin.acts;

import java.lang.reflect.Method;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

/**
 * 
 *
 * @author zhao.tb
 */
public class BaseActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d(""+this.getComponentName(), "Create");
	}

	public void startActivity(Intent intent) {
		super.startActivity(intent);

	}

	/**
	 * startActivity
	 * 
	 * @param i
	 * @param toLeft
	 *            True or False to right.
	 * @Description TODO
	 */
	public void startActivity(Intent i, boolean toLeft) {
		super.startActivity(i);
		startPendingAnimation(toLeft);
	}
	
	/**
	 * startPendingAnimation
	 * @param toLeft TODO
	 * @Description
	 *   TODO
	 */
	public void startPendingAnimation(boolean toLeft){
		Method method = null;
		try {
			if ((method = this.getClass().getMethod("overridePendingTransition", int.class, int.class)) != null) {
				if (toLeft) {
					method.invoke(this, R.anim.slide_enter, R.anim.slide_out);
				} else {
					method.invoke(this, R.anim.slide_outt, R.anim.slide_enterr);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/* (Override)
	 * @see android.app.Activity#onDestroy()
	 */
	@Override
	protected void onDestroy() {
		Log.d(""+this.getComponentName(), "Destroy");
		super.onDestroy();
	}

}